//gsoap ns service name:	netbook Write and Share your Notes.
//gsoap ns service style:	rpc
//gsoap ns service encoding:	encoded
//gsoap ns service namespace:	http://localhost:8888/netbook.wsdl
//gsoap ns service location:	http://localhost:8888/netbookserver.cgi
//gsoap ns schema namespace:	urn:netbook

/** netbook data model. **/
typedef struct UserStruct {
   uint32_t id;
   char	*nickname;
   char *mail;
   char *time_USCOREreg;
   char *time_USCORElastlogin;
   char *time_USCORElastupdate;
   uint8_t attribute;
}UserStruct;

#define ST_USER_ID		(1<<0)
#define ST_USER_NICKNAME	(1<<1)
#define ST_USER_MAIL		(1<<2)
#define ST_USER_TIME_REG	(1<<3)
#define ST_USER_TIME_LASTLOGIN	(1<<4)
#define ST_USER_TIME_LASTUPDATE	(1<<5)
#define ST_USER_ATTRIBUTE	(1<<6)

typedef struct NoteStruct {
    uint64_t id;
    uint32_t owner_USCOREid;
    char *uuid;
    char *title;
    char *content;
    char *time_USCOREcreate;
    char *time_USCORElastupdate;
    uint8_t version;
    uint32_t attribute;
}NoteStruct;

// struct fields.
#define ST_NOTE_ID		(1<<0)
#define ST_NOTE_OWNER_ID	(1<<1)
#define ST_NOTE_UUID		(1<<2)
#define ST_NOTE_TITLE		(1<<3)
#define ST_NOTE_CONTENT		(1<<4)
#define ST_NOTE_TIME_CREATE	(1<<5)
#define ST_NOTE_TIME_LASTUPDATE (1<<6)
#define ST_NOTE_VERSION		(1<<7)
#define ST_NOTE_ATTRIBUTE	(1<<8)

// attribute 1-meaning.
#define ST_NOTE_ATTR_PUBLIC    (1<<0)

typedef struct FavoriteStruct {
    uint32_t user_USCOREid;
    uint64_t note_USCOREid;
    uint32_t owner_USCOREid;
    char *click_USCOREtime;
    uint8_t status;
}FavoriteStruct;

#define ST_FAVORITE_USER_ID	(1<<0)
#define ST_FAVORITE_NOTE_ID	(1<<1)
#define ST_FAVORITE_OWNER_ID	(1<<2)
#define ST_FAVORITE_CLICK_TIME	(1<<3)
#define ST_FAVORITE_STATUS		(1<<4)

typedef struct TagStruct {
    char *name;
    uint32_t count_USCOREref;
}TagStruct;

#define ST_TAG_NOTE_ID	(1<<0)
#define ST_TAG_USER_ID	(1<<1)
#define ST_TAG_TAG	(1<<2)

typedef struct ShareStruct {
    uint64_t note_USCOREid;
    uint32_t user_USCOREid;
    uint32_t owner_USCOREid;
    uint32_t attribute;
}ShareStruct;
#define ST_SHARED_NOTE_ID	(1<<0)
#define ST_SHARED_USER_ID	(1<<1)
#define ST_SHARED_OWNER_ID	(1<<2)
#define ST_SHARED_ATTRIBUTE	(1<<3)

/********************************************\
 * netbook data array-type definition.
\********************************************/
typedef struct UserArray {
    UserStruct *__ptr;
    int __size;
}UserArray;

typedef struct NoteArray {
    NoteStruct *__ptr;
    int __size;
}NoteArray;

typedef struct FavoriteArray {
    FavoriteStruct *__ptr;
    int __size;
}FavoriteArray;

typedef struct TagArray {
    TagStruct *__ptr;
    int __size;
}TagArray;

/** Authentication **/
int ns__login(char *mail, char *passwd, char **session);
int ns__logout(char *session, int *status);

/** User **/
// insert, update, remove
int ns__register(char *mail, char *passwd, UserStruct **user);
int ns__setMyAttribute(char *session, uint8_t attribute, int *status);
int ns__changeMyNickname(char *session, char *nickname, int *status);
int ns__changeMyPasswd(char *session, char *old_USCOREpasswd, char *new_USCOREpasswd, int *status);
// verify
// get
int ns__getUserById(char *session, uint32_t user_USCOREid, UserStruct **user);
int ns__getUserByMail(char *session, char *mail, UserStruct **user);
int ns__getMyself(char *session, UserStruct **user);
int ns__getUserList(char *session, UserArray **result);

/** Note **/
// insert, update, remove
int ns__insertMyNote(char *session, char *title, char *content, NoteStruct **note);
int ns__updateMyNote(char *session, uint64_t note_USCOREid, char *title, char *content, int *status);
int ns__removeMyNote(char *session, uint64_t note_USCOREid, int *status);

//int ns__setMyNoteAttribute(char *session, uint64_t note_USCOREid, uint32_t attribute, int *status);
// verify
// get
int ns__getNoteById(char *session, uint64_t note_USCOREid, uint32_t field, NoteStruct **note);

int ns__getAllPublicNoteNumber(char *session, uint64_t *number);
int ns__getAllPublicNoteList(char *session, uint64_t start, uint32_t count, uint32_t field, NoteArray **result);

int ns__getMyNoteNumber(char *session, uint64_t *number);
int ns__getMyNoteList(char *session, uint64_t start, uint32_t count, uint32_t field, NoteArray **result);

/*
int ns__getUserSharedNoteNumber(char *session, uint32_t user_id, uint32_t *number);
int ns__getUserSharedNoteList(char *session, uint32_t user_id, uint64_t start, uint32_t count, uint32_t field, NoteArray **result);

int ns__getAllSharedNoteNumber(char *session, uint32_t *number);
int ns__getAllSharedNoteList(char *session, uint64_t start, uint32_t count, uint32_t field, NoteArray **result);

int ns__getUserPublicNoteNumber(char *session, uint32_t user_id, uint32_t *number);
int ns__getUserPublicNoteList(char *session, uint32_t user_id, uint64_t start, uint32_t count, uint32_t field, NoteArray **result);
*/
/*
int ns__setMyNoteAttribute(char *session, uint64_t note_USCOREid, uint32_t attribute, int *status);

int ns__getUserSharedNoteNumber(char *session, uint32_t user_USCOREid, uint32_t *number);
int ns__getUserSharedNoteList(char *session, uint32_t user_USCOREid, uint32_t start, uint32_t count, uint32_t field, NoteArray **result);

int ns__getAllSharedNoteNumber(char *session, uint64_t *number);
int ns__getAllSharedNoteList(char *session, uint64_t start, uint32_t count, uint32_t field, NoteArray **result);

int ns__getUserPublicNoteNumber(char *session, uint32_t user_USCOREid, uint32_t *number);
int ns__getUserPublicNoteList(char *session, uint32_t user_USCOREid, uint32_t start, uint32_t count, uint32_t field, NoteArray **result);
*/

//** Share **/
/*
// insert, update, remove
int ns__addShare(char *session, uint64_t note_USCOREid, uint32_t user_USCOREid, int *status);
int ns__removeShare(char *session, uint64_t note_USCOREid, uint32_t user_USCOREid, int *status);
// verify
// get
int getNoteShareUserList(char *session, uint64_t note_USCOREid, ShareArray **result);
int getNoteShareAttribute(char *session, uint64_t note_USCOREid, uint32_t user_USCOREid, uint8_t *attribute);
int setNoteShareAttribute(char *session, uint64_t note_USCOREid, uint32_t user_USCOREid, uint8_t attribute, int *status);
*/

/** Tags **/
/*
// insert, update, remove
int ns__addTag(char *session, uint64_t note_USCOREid, char *tag, int *status);
int ns__removeTag(char *session, uint64_t note_USCOREid, char *tag, int *status);
int ns__setNoteTags(char *session, char **tags, int *status);
// verify
// get
int ns__getNoteTags(char *session, uint64_t note_USCOREid, char **result);
int ns__getMyTagNumber(char *session, uint64_t *number);
int ns__getMyTagList(char *session, uint64_t start, uint32_t count, TagArray **result);
*/

/** Favorite **/
/*
// insert, update, remove
int ns__addFavorite(char *session, uint64_t note_USCOREid, int *status);
int ns__removeFavorite(char *session, uint64_t note_USCOREid, int *status);
// verify
// get
int ns__getMyFavorChangeNumber(char *session, uint64_t *number);
int ns__getFavoriteNumber(char *session, uint32_t user_USCOREid, uint64_t *number);
int ns__getFavoriteList(char *session, uint32_t user_USCOREid, uint64_t start, uint32_t count, FavoriteArray **result);
int ns__resetMyFavoriteStatus(char *session, uint64_t note_USCOREid, int *status);
*/
